package com.example.mobiledatapackage.service;

import com.example.mobiledatapackage.domain.Package;
import com.example.mobiledatapackage.domain.pojo.PackageRecommendQueryCondDto;
import com.example.mobiledatapackage.mapper.PackageMapper;
import com.example.mobiledatapackage.request.pkg.PackageCondition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class PackageService {

    @Autowired
    private PackageMapper packageMapper;

    @Autowired
    private RecommendService recommendService;


    public int deleteByPrimaryKey(String id) {
        return packageMapper.deleteByPrimaryKey(id);
    }


    public int insert(Package record) {
        return packageMapper.insert(record);
    }


    public int insertSelective(Package record) {
        return packageMapper.insertSelective(record);
    }


    public Package selectByPrimaryKey(String id) {
        return packageMapper.selectByPrimaryKey(id);
    }

    public List<Package> selectAll() {
        return packageMapper.selectAll();
    }


    public int updateByPrimaryKeySelective(Package record) {
        return packageMapper.updateByPrimaryKeySelective(record);
    }


    public int updateByPrimaryKey(Package record) {
        return packageMapper.updateByPrimaryKey(record);
    }

    /**
     * 按照 cond 来进行查询 package
     *
     * @param cond 查询的条件
     * @return 查询的结果
     */
    public List<Package> recommendQueryByCond(PackageRecommendQueryCondDto cond) {
        return packageMapper.recommendQueryByCondition(cond);
    }

    public List<Package> selectConditional(PackageCondition cond) {
        cond.setName("%" + cond.getName() + "%");
        return packageMapper.selectConditional(cond);
    }
}